package data.preprocessing;

public class StringProcessor_MarkURL implements StringProcessor{

	public String map(String from) {
		
		//from.replaceAll("((https?|ftp)://(w{3}\.)?)(?<!www)(\w+-?)*\.([a-z]{2,4})", "URL");
		//(((?:https?|ftp)://\S+)(\s|\z)
		//((?<!//)(www\.)\S+)(\s|\z)
		
		from=from.replaceAll("((?:https?|ftp)://\\S+)(\\s|\\z)", " URL ");
		from=from.replaceAll("((?<!//)(www\\.)\\S+)(\\s|\\z)", " URL ");
		return (from);
		
	}
	
	public static void main(String[] args){
		//String text = "coucou++  m**** 67";
		//String text = "http://www.developpez.net/forums/d356316/php/langage/regex/verification-url-expression-reguliere/ balbal";
		String text = "www.developpez.net/forums/d356316/php/langage/regex/verification-url-expression-reguliere/ balbal";
		StringProcessor sp = new StringProcessor_MarkURL();
		System.out.println(sp.map(text));
	}

}
